#!/bin/sh

TARGET_PATH="/cygdrive/d"
KASSIOPEIA_FINAL_NAME="kassiopeia-1.0-SNAPSHOT"
MAVEN_FLAGS=-o

echo
echo "--- FOR DEVELOPING PURPOSES ONLY ---"
echo "This script creates Kassiopeia agent distribution under specified location"
echo "NOTE: Maven is operating in OFFLINE MODE to speed-up building process!"
echo
echo "TARGET PATH: $TARGET_PATH (change it if you like)"
echo

echo &&
echo "[#] Building agent.." &&
echo &&
mvn clean install $MAVEN_FLAGS &&
cd agent-distribution &&
cd target/$KASSIOPEIA_FINAL_NAME &&
echo &&

echo "[#] Copying distribution to: $TARGET_PATH/$KASSIOPEIA_NAME" &&
echo &&
rm -fr "$TARGET_PATH/$KASSIOPEIA_FINAL_NAME" &&
cp -fr $KASSIOPEIA_FINAL_NAME $TARGET_PATH

#for i in {1..3}
#do
#   KASSIOPEIA_NAME="$KASSIOPEIA_FINAL_NAME-$i"
#   echo "[#] Copying distribution to: $TARGET_PATH/$KASSIOPEIA_NAME"
#   echo
#   rm -fr "$TARGET_PATH/$KASSIOPEIA_NAME"
#   cp -fr $KASSIOPEIA_FINAL_NAME $TARGET_PATH
#   mv "$TARGET_PATH/$KASSIOPEIA_FINAL_NAME" "$TARGET_PATH/$KASSIOPEIA_NAME"
#done

echo "[#] Done."

